home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / extendCurvePresetArgList.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.8 KB  |  182 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date: April 23, 1997
  22. //  Author:        sjt 
  23. //
  24. //  Description:
  25. //      The extendCurvePreset() procedure executes a extend curve operation on 
  26. //      a curve based on the extend option vars.
  27. //
  28. //  Input Arguments:
  29. //      None.
  30. //
  31. //  Return Value:
  32. //      None.
  33. //
  34.  
  35. proc string pieceTogetherExtendCurveCmd(
  36.     int $cos,
  37.      int $history,
  38.     int $method,
  39.     int $extendType,
  40.     float $distance,
  41.     float $toPointX,
  42.     float $toPointY,
  43.     float $toPointZ,
  44.     int $start,
  45.     int $join,
  46.     int $removeMultKnots,
  47.     int $replaceOriginal )
  48. //
  49. //    Description :
  50. //        Piece together a extendCurve command.
  51. //
  52. {
  53.     string $cmd;
  54.     $cmd = "extendCurve -cos " + $cos;
  55.  
  56.     // construction history
  57.     $cmd = $cmd + " -ch " + $history;
  58.     
  59.     // extend method
  60.     //
  61.     if( $method == 0 ) {
  62.         $cmd = $cmd + " -em 0";
  63.         $cmd = $cmd + " -et " + $extendType;
  64.         $cmd = $cmd + " -d " + $distance;
  65.     }
  66.     else {
  67.         $cmd = $cmd + " -em 2";
  68.         $cmd = $cmd + " -px " + $toPointX;
  69.         $cmd = $cmd + " -py " + $toPointY;
  70.         $cmd = $cmd + " -pz " + $toPointZ;
  71.     }
  72.  
  73.     $cmd = $cmd + " -s " + $start;
  74.  
  75.     // join, removeMultKnots, replaceOriginal
  76.     //
  77.     if( $join == 0 ) {
  78.         // when join is off, removeMultKnots & replace original cannot be done
  79.         $cmd = $cmd + " -jn false -rmk false -rpo false";
  80.     }
  81.     else {
  82.         $cmd = $cmd + " -jn true";
  83.         if ( $removeMultKnots == 1 ) $cmd = $cmd + " -rmk true";
  84.         else $cmd = $cmd + " -rmk false";
  85.         if ( $replaceOriginal == 1 ) $cmd = $cmd + " -rpo on";
  86.         else $cmd = $cmd + " -rpo off";
  87.     }
  88.  
  89.     $cmd += " %s ";
  90.  
  91.     return $cmd;
  92.  
  93. }
  94.  
  95. global proc extendCurvePresetArgList(
  96.     string $version,
  97.     string $args[] )
  98. //
  99. //    ExtendCurve with the preset options.
  100. //    Use this proc when operation dragged to Shelf.
  101. //
  102. {
  103.     int $cos, $history, $method, $extendType;
  104.     float $distance, $toPointX, $toPointY, $toPointZ;
  105.     int $start, $join, $removeMultKnots, $replaceOriginal;
  106.  
  107.     // Depending on the version, the argument lists are different.
  108.     // Version 1 of this procedure had 11 args only.
  109.     // Versions after 1 have 12 args, where the first arg is for COS capability
  110.     //
  111.     if( $version == "1") {
  112.         $cos =                 0;
  113.          $history =             $args[0];
  114.         $method =             $args[1];
  115.         $extendType =         $args[2];
  116.         $distance =         $args[3];
  117.         $toPointX =         $args[4];
  118.         $toPointY =         $args[5];
  119.         $toPointZ =         $args[6];
  120.         $start =             $args[7];
  121.         $join =             $args[8];
  122.         $removeMultKnots =     $args[9];
  123.         $replaceOriginal =     $args[10];
  124.     } else {
  125.         $cos =                 $args[0];
  126.          $history =             $args[1];
  127.         $method =             $args[2];
  128.         $extendType =         $args[3];
  129.         $distance =         $args[4];
  130.         $toPointX =         $args[5];
  131.         $toPointY =         $args[6];
  132.         $toPointZ =         $args[7];
  133.         $start =             $args[8];
  134.         $join =             $args[9];
  135.         $removeMultKnots =     $args[10];
  136.         $replaceOriginal =     $args[11];
  137.     }
  138.  
  139.     string $cmd = pieceTogetherExtendCurveCmd( $cos, $history, $method, $extendType, $distance, $toPointX, $toPointY, $toPointZ, $start, $join, $removeMultKnots, $replaceOriginal );
  140.  
  141.     // Get the list of nurbs curves selected.
  142.     //
  143.     global int $gSelectNurbsCurvesBit;
  144.     global int $gSelectCurvesOnSurfacesBit;
  145.     global int $gSelectCurveParmPointsBit;
  146.     string $curveList[];
  147.  
  148.     if( $cos ) {
  149.         $curveList = `filterExpand -ex true -sm $gSelectCurvesOnSurfacesBit`;
  150.     }
  151.     else {
  152.         $curveList = `filterExpand -ex true -sm $gSelectNurbsCurvesBit -sm $gSelectCurvesOnSurfacesBit`;
  153.     }
  154.  
  155.     int $numCurves = size($curveList);
  156.     if ( $numCurves == 0 )
  157.     {
  158.         error("No curves selected to extend.");
  159.     }
  160.     else 
  161.     {
  162.         string $extendResults[] = executeForEachObject( $curveList, $cmd );
  163.  
  164.         // select the results.
  165.         //
  166.         int $resultCount = size($extendResults);
  167.         if ( $resultCount > 0 ) 
  168.         {
  169.             string $selectString;
  170.             $selectString = "select ";
  171.             int $i;
  172.             for ( $i = 0; $i < $resultCount; $i++ ) {
  173.                 $selectString +=  $extendResults[$i];
  174.                 $selectString += " ";
  175.             }
  176.             $selectString += ";";
  177.             select -cl;
  178.             eval($selectString);
  179.         }
  180.     }
  181. }
  182.